package com.db.gffxo.epi.test;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import junit.framework.TestCase;
import com.db.gffxo.epi.domain.Event;
import com.db.gffxo.epi.repository.EventDaoGen;


public class EventTestGen extends TestCase {

private DriverManagerDataSource dataSource;
private EventDaoGen dao;
private Event Event;
	public void setUp() {
		dataSource = new DriverManagerDataSource();
		dataSource.setDriverClassName("com.mysql.jdbc.Driver");
		dataSource.setUrl("jdbc:mysql:///epi");
		dataSource.setUsername("epi");
		dataSource.setPassword("epiepi");
		dao= new EventDaoGen();
		dao.setDataSource(dataSource);

		Event = new Event();
		Event.setEventId(666);
		Event.setEventType("EventType");
		Event.setStatus("Status");
		Event.setKeyInfo("KeyInfo");
	}

	public void testInsertAndGet () {

		dao.insert(Event);

		List dbaEvents = dao.getEvent();

		Event dbaEvent = (Event) dbaEvents.get(0);

		assertEquals("EventId",Event.getEventId(),dbaEvent.getEventId());
		assertEquals("EventType",Event.getEventType(),dbaEvent.getEventType());
		assertEquals("Status",Event.getStatus(),dbaEvent.getStatus());
		assertEquals("KeyInfo",Event.getKeyInfo(),dbaEvent.getKeyInfo());
	}

}